/**
 * @file 剪花布条
 * @author Ruiming Guo (guoruiming@stu.scu.edu.cn)
 * @brief
 * 一块花布条，里面有些图案，另有一块直接可用的小饰条，里面也有一些图案。
 * 对于给定的花布条和小饰条，计算一下能从花布条中尽可能剪出几块小饰条来呢？
 * @see https://vjudge.net/solution/36244314
 * @version 1.0
 * @date 2022-05-08
 *
 * @copyright Copyright (c) 2022
 *
 **/

#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
char text[N], pattern[N];
#define next _next  // not using std::next
int next[N];
int textLen, patternLen;
int main() {
  while (cin >> text + 1 >> pattern + 1) {
    int nMatch = 0;
    if (text[1] == '#') break;
    textLen = strlen(text + 1), patternLen = strlen(pattern + 1);
    // Build the next array
    for (int iPos = 2, iPattern = 0; iPos <= patternLen; ++iPos) {
      while (iPattern && pattern[iPos] != pattern[iPattern + 1])
        iPattern = next[iPattern + 1];
      if (pattern[iPos] == pattern[iPattern]) iPattern++;
      next[iPos] = iPattern;
    }
    for (int iText = 1, iPattern = 0; iText <= textLen; ++iText) {
      while (iPattern && text[iText] != pattern[iPattern + 1])
        iPattern = next[iPattern];
      if (text[iText] == pattern[iPattern + 1]) ++iPattern;
      if (iPattern == patternLen) {
        nMatch++;
        iPattern = 0;  // 一般 kmp 在这里是 iPattern = next[iPattern]
      }
    }
    cout << nMatch << endl;
  }
}
